<template>
  <div class="mobile-journal-view common-mobile-view">
    <journal-calendar />

    <draggable-button @click="addClick"/>
  </div>
</template>

<script lang="ts" setup>
import JournalCalendar from '@/components/Journal/JournalCalendar.vue'
import DraggableButton from '@/components/Common/DraggableButton.vue'
import { useJournalStore } from '@/store/journal.ts'
import { useRouter } from 'vue-router'
import { onMounted } from 'vue'
import { getCurrentMonth, getStartEndDate } from 'vue3-common/utils/dateUtil'

const journalStore = useJournalStore()
const router = useRouter()

onMounted(async () => {
  const dateInfo = getStartEndDate(getCurrentMonth(), 'month')
  journalStore.queryInfo.startDate = dateInfo[0]
  journalStore.queryInfo.endDate = dateInfo[1]
  await journalStore.refreshInfo()
})

const addClick = () => {
  journalStore.journalApiType = 'ADD'
  journalStore.currentJournal = journalStore.getEmptyJournal()
  router.push({ name: 'JournalDetailId', params: { id: 0 } })
}
</script>

<style lang="scss">
.mobile-journal-view {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
</style>
